import React, { Component } from 'react'
import axios from 'axios'

export default class App extends Component {
  getStudentData = () => {
    // 发送网络请求
    axios.get('http://localhost:3000/api1/students').then(
      response => {console.log('成功', response.data)},
      error => {console.log('失败', error)}
    )
  }
  getCarData = () => {
    // 发送网络请求
    axios.get('http://localhost:3000/api2/cars').then(
      response => {console.log('成功', response.data)},
      error => {console.log('失败', error)}
    )
  }
  render() {
    return (
      <div>
        <button onClick={this.getStudentData}>获取学生的数据</button>
        <button onClick={this.getCarData}>获取汽车的数据</button>
      </div>
    )
  }
}
